<?php
// 定义应用目录
define('APP_PATH', __DIR__ . '/api/');
define('RUNTIME_PATH', __DIR__ . '/runtime/api/');
define('VENDOR_PATH',__DIR__ . '/system/vendor/');
// 加载框架引导文件
try {
    require __DIR__ . '/system/thinkphp/start.php';
}catch(\Exception $e){
    $error  = array(
        'line'      => '('.$e->getLine().')'.$e->getFile(),
        'message'   => $e->getMessage(),
        'trace'     => $e->getTraceAsString(),
    );
    $log    = json_encode($error);
    $now    = date('Y-m-d H:i:s');
    $destination    = RUNTIME_PATH.'exception-'.date('y_m_d').'.log';
    error_log("[{$now}] ".$_SERVER['REMOTE_ADDR'].' '.$_SERVER['REQUEST_URI']."\r\n{$log}\r\n", 3,$destination);
    
    if( function_exists('out') ){
        out('exe_fail', null, null, $error);
    } else {
        echo json_encode(array(
            'status'    => 'exe_fail',
            'info'      => '执行失败',
            'data'      => array(),
            'debug'     => $error,
        ));
        exit;
    }
}